package com.douqu.game.core.util;

import com.douqu.game.core.config.InitDataConfig;
import com.douqu.game.core.config.StableDataConfig;
import com.douqu.game.core.config.card.CardConfig;
import com.douqu.game.core.config.challenge.OfficialRankConfig;
import com.douqu.game.core.e.E_InitDataType;
import com.douqu.game.core.e.E_ScrollNoticeType;
import com.douqu.game.core.e.E_StableDataType;
import com.douqu.game.core.factory.ConstantFactory;
import com.douqu.game.core.factory.DataFactory;
import com.douqu.game.core.factory.WordFactory;

import java.util.List;

/**
 * @Author: wzf
 * @Description: 公告管理
 * @Date: 2018-01-28 20:44
 */
public class NoticeUtils {


    /**
     * 获取滚动公告
     * @param noticeType
     * @param playerName
     * @param param
     * @return
     */
    public static String getScrollNotice(E_ScrollNoticeType noticeType, String playerName, int... param){
        String param1 = null;
        String param2 = null;
        String param3 = null;

        StableDataConfig stableDataConfig = DataFactory.getInstance().getGameObject(DataFactory.STABLE_DATA_KEY, E_StableDataType.GLOBAL_NOTICE_CONDITION.getCode());
        if (stableDataConfig == null){
            LogUtils.error("StableDataConfig error ->" + "no have type " + E_StableDataType.GLOBAL_NOTICE_CONDITION.getMsg());
            return null;
        }
      switch (noticeType){
          case JOIN_LEGION:
              int cardId = param[0];
              CardConfig config = DataFactory.getInstance().getGameObject(DataFactory.CARD_KEY, cardId);
              if(config == null){
                return null;
              }

              if(config.quality == ConstantFactory.QUALITY_ORANGE ){
                  param1 = DataFactory.getInstance().getWord(WordFactory.NOTICE_CARD_ORANGE, config.name);
              }else if(config.quality == ConstantFactory.QUALITY_RED){
                  param1 = DataFactory.getInstance().getWord(WordFactory.NOTICE_CARD_RED, config.name);
              }else{
                  return null;
              }
              return DataFactory.getInstance().getWord(E_ScrollNoticeType.JOIN_LEGION.getCode(), playerName,  param1);
          case ARENA_RANK_UP:
              int arenaRank = param[0];
              if(arenaRank < stableDataConfig.intArray[0]){
                  return DataFactory.getInstance().getWord(E_ScrollNoticeType.ARENA_RANK_UP.getCode(), playerName, arenaRank);
              }else {
                  return null;
              }

          case OFFICIAL_RANK_UP:
              int camp = param[0];
              int randId = param[1];
              if(randId % 100 > stableDataConfig.intArray[1]){
                  return null;
              }
              param1 = WordFactory.getCampStr(camp);

              OfficialRankConfig rankConfig = DataFactory.getInstance().getGameObject(DataFactory.OFFICIAL_RANK_KEY, randId);
              if(rankConfig == null){
                  return null;
              }
              if(randId % 100 == 1){
                  param3 = DataFactory.getInstance().getWord(WordFactory.NOTICE_OFFICIAL_RANK_1, rankConfig.name);
              }else {
                  param3 = DataFactory.getInstance().getWord(WordFactory.NOTICE_OFFICIAL_RANK_2_5, rankConfig.name);
              }
              return DataFactory.getInstance().getWord(E_ScrollNoticeType.OFFICIAL_RANK_UP.getCode(), playerName,  param1, randId % 100, param3);
          case EXPEDITION_UP:
              int level = param[0];
              if(level >= stableDataConfig.intArray[2]){
                  return DataFactory.getInstance().getWord(E_ScrollNoticeType.EXPEDITION_UP.getCode(), playerName,  level);
              }else {
                  return null;
              }

          case HERO_STAR_UP:
              int card = param[0];
              int star = param[1];
              if(star < stableDataConfig.intArray[3]){
                return null;
              }
              CardConfig config1 = DataFactory.getInstance().getGameObject(DataFactory.CARD_KEY, card);
              if(config1 == null){
                  return null;
              }
              if(config1.quality == ConstantFactory.QUALITY_PURPLE ){
                  param1 = DataFactory.getInstance().getWord(WordFactory.NOTICE_CARD_PURPLE, config1.name);
              }else if(config1.quality == ConstantFactory.QUALITY_ORANGE ){
                  param1 = DataFactory.getInstance().getWord(WordFactory.NOTICE_CARD_ORANGE, config1.name);
              }else if(config1.quality == ConstantFactory.QUALITY_RED){
                  param1 = DataFactory.getInstance().getWord(WordFactory.NOTICE_CARD_RED, config1.name);
              }else{
                  return null;
              }

              return DataFactory.getInstance().getWord(E_ScrollNoticeType.HERO_STAR_UP.getCode(), playerName,  param1, star);
      }
      return null;
  }
}
